package com.midian.model.advertisepic;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.midian.common.utils.StringUtil;
import com.midian.model.common.BaseModel;
import com.midian.model.pic.Pic;

/**
 * 启动页图片
 * 
 */
@Entity
@Table(name = "advertise_pic")
public class AdvertisePic extends BaseModel{
	/**图片id*/
	private String picId;
	/**图片链接*/
	private String url;
	/**图片id*/
	@ManyToOne(optional=true,fetch=FetchType.LAZY)
	@NotFound(action = NotFoundAction.IGNORE)
	@JoinColumn(name="picId",insertable=false,updatable=false)
	private Pic indexAdvertisePic;
	
	public String getPicId() {
		return picId;
	}
	public void setPicId(String picId) {
		this.picId = picId;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	
	public Pic getIndexAdvertisePic() {
		return indexAdvertisePic;
	}
	public void setIndexAdvertisePic(Pic indexAdvertisePic) {
		this.indexAdvertisePic = indexAdvertisePic;
	}
	
	/**advertisePic地址*/
	@Transient
	public String getAdvertisePicIp() {
		String advertisePicIp="";
		if (this.indexAdvertisePic!=null) {
			advertisePicIp = StringUtil.getImageTips(this.indexAdvertisePic.getId());
		}
		return advertisePicIp;
		
	}
	
	
}
